/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * popWin.java
 *
 * Created on Jun 5, 2011, 12:49:33 PM
 */
package Client.GUI.Popups;

import Client.Net.*;
import Client.*;
import Library.Events.TimeEvent;
import Library.Game.*;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.*;
import java.util.List;
import Client.GUI.*;
/**
 *
 * @author Administrator
 */
public class popWin extends AbstractPopup
{

    /** Creates new form popWin */
    public popWin(ICommunication communication, IPopupContainer container) 
    {
       super(communication, container);
       initComponents();        
       m_Communication = communication;
       m_Container = container;
       
       try
       {
           String winner = m_Communication.getService().getGame().getGameWinner();
           winLabel.setText("Player " + winner + " has won this game!");
       } 
       catch(Exception ex)
       {
          String s = ex.getMessage();
       }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        winLabel = new javax.swing.JLabel();
        closeClient = new javax.swing.JButton();

        setBackground(new java.awt.Color(204, 204, 204));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel1.setText("The game is over");

        winLabel.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        winLabel.setText("Player X has Won this game!");

        closeClient.setText("Close");
        closeClient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeClientActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(winLabel)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(271, 271, 271)
                        .addComponent(closeClient)))
                .addContainerGap(275, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(37, 37, 37)
                .addComponent(winLabel)
                .addGap(111, 111, 111)
                .addComponent(closeClient)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void closeClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeClientActionPerformed
        try
        {
                //m_Communication.getService().leaveGame();
		unregister();
                // Go back to GameList
                m_Communication.SetContent(new pnlGameList(m_Communication));
        } 
        catch(Exception ex)
        {
            String s = ex.getMessage();
        }
    }//GEN-LAST:event_closeClientActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton closeClient;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel winLabel;
    // End of variables declaration//GEN-END:variables
}
